package com.woniu.controller;

import com.woniu.dto.DrugDto;
import com.woniu.entity.Drug;
import com.woniu.service.DrugService;
import com.woniu.utils.ResponseUtil;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @Author: zcy
 * @Create: 2025/11/1 17:06
 */
@RestController
@RequestMapping("/drug")
public class DrugController {
    @Resource
    private DrugService drugService;
    @PostMapping("/find")
    public ResponseUtil findAll(@RequestBody DrugDto drugDto){
        return drugService.findAll(drugDto);
    }
    @PostMapping("/add")
    public ResponseUtil add(@RequestBody Drug drug){
        return drugService.add(drug);
    }
    @PutMapping("/update")
    public ResponseUtil update(@RequestBody Drug drug){
        return drugService.update(drug);
    }
    @DeleteMapping("/delete/{id}")
    public ResponseUtil delete(@PathVariable Long id){
        return drugService.delete(id);
    }
    @GetMapping
    public ResponseUtil findDrugs(){
        return drugService.findDrugs();
    }
}
